package com.datastructure.test.twosum;

public class TwoSum {
    public int[] twoSum (int[] numbers, int target) {
        // write code here
        int[] data = new int[2];
        for (int i = 0; i < numbers.length; i++) {
            if(numbers[i]>=target){
                continue;
            }
            int j = i+1;
            while (j< numbers.length){
                if(numbers[i]+numbers[j]==target){
                    data[0]=i+1;
                    data[1]=j+1;
                    return data;
                }
                j++;
            }
        }
        return data;
    }
    int result = 0;
    public int Sum_Solution(int n) {
       computeSum(n);
       return result;
    }

    private void computeSum(int n) {
        if(n==0){
            return;
        }
        result+=n;
        computeSum(n-1);
    }
}
